var utils = require('../../utils/util.js');
var base64Js = require('../../utils/base64.js');
var md5Js = require('../../utils/md5.js');
var app = getApp();
var object = {};
object.data = {};
Page({
  data:{
    details: [],
  },
  onLoad:function(options){
     try{
         var _this = this;
        //获取缓存的用户对象信息
        var user_info =  wx.getStorageSync('user_info');
        //如果用户信息不为空则请求首页接口获取产品等信息。
        if(user_info){
          var request_data = user_info.user_itmes;
          var uid         = request_data.id.toString();
          var private_key = user_info.private_key;
          var t           =  new Date().getTime().toString();
          var k           = md5Js.hex_md5(private_key+t);//key
          var parms_url   = app.request_url+'C_Enterprisestyle/?';
          parms_url += 'enterpriseId='+request_data.enterpriseId;
          parms_url += '&uid='+request_data.id;
          parms_url += '&userType='+request_data.type;
          parms_url += '&t='+t;
          parms_url += '&k='+k;
          parms_url += '&v='+app.version;
          // parms_url = 'http://rest.test.freshqiao.com/C_Enterprisestyle/?enterpriseId=79&userType=1&t=1486720233112&k=0dc3828594dd73cf61f9e62beca5fe56&uid=100000202&v=2';
          //调用产品页接口
          wx.request({
            url: parms_url,
            method: 'GET',
            success: function(res){
               var respones = res;
               //请求成功分配模板变量
               if((respones.statusCode=='200')&&(respones.data.Success==1)){
                   //分配模板变量
                   console.log(res.data.CallInfo.url);
                  _this.setData({enterprisestyle:res.data.CallInfo.url})
               }
            }
          })
        }
    }catch(e){
      console.log('error=>'+e.message);return false;
    }
  },
  onReady:function(){
    // 页面渲染完成
  },
  onShow:function(){
    // 页面显示
  },
  onHide:function(){
    // 页面隐藏
  },
  onUnload:function(){
    // 页面关闭
  },

})